package com.yingsheng.bi.hks.config.props;

import lombok.Data;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

@Data
public class SmsProperties {

    private String appId;

    private String signName;

    private String secretId;

    private String secretKey;

    private Long defaultTimeout;

    private Boolean sendLimitCheck = true;

    private Map<String, Long> expireMapping = new HashMap<>();

    private Map<String, String> templateIdMapping = new HashMap<>();

    public Long getExpireTime(String key) {
        if (StringUtils.hasText(key) && !CollectionUtils.isEmpty(this.expireMapping)) {
            Long timeout = this.expireMapping.get(key);
            if (timeout != null) {
                return timeout;
            }
        }
        return this.defaultTimeout;
    }

    public String getTemplateId(String key) {
        if (StringUtils.hasText(key) && !CollectionUtils.isEmpty(this.templateIdMapping)) {
            String templateId = this.templateIdMapping.get(key);
            if (StringUtils.hasText(templateId)) {
                return templateId;
            }
        }
        return null;
    }

}
